{% extends 'layout.html' %}
{% block main %}
    <script type=text/javascript>
        $(function() {
            function filltbress(ress){
                var tr='';
                $.each(ress,function(i,item){
                    tr+='<tr><td>'+(i+1)+'</td><td>'+item.CommID+'</td><td><a target="_blank" href="/comm/'+item.CommID+'">'+item.ProjectName+'</a></td><td>'+item.InstallDate+'</td><td>'+item.DistrictName+'</td></tr>';

                });
                $("#tb_comms tbody").html(tr);
            }

            $("select[name='areaid']").change(function(){
                $.getJSON("/_json_comms",{areaid:$("select[name='areaid']").val()},function(data){
                    filltbress(data.result);
                });

            });
            $("select[name='areaid']").trigger('change');
        });
    </script>
            <form class="ym-form ym-columnar" method="post">
                <div class="ym-grid">
                    <div class="ym-g50 ym-gl">
                        <div class="ym-gbox ym-fbox-text">
                            <label for="projectname">小区名称</label>
                            <input name="projectid" type="hidden" value="{{ comm.ProjectID }}" />
                            <input name="projectname" value="{{ comm.ProjectName }}" />
                        </div>
                    </div>
                    <div class="ym-g50 ym-gr">
                        <div class="ym-gbox ym-fbox-select">
                            <label for="projectname">片区</label>

                            <select name="areaid">
                            {% for area in areas %}
                                <option value="{{ area.AreaID }}" {% if area.AreaID==comm.AreaID %}selected="selected"{% endif %}>{{ area.AreaName }}</option>
                            {% endfor %}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="ym-fbox-button">

                {% if commid %}
                    <input type="submit" class="ym-button" name="action" value="保存" />
                    <input type="submit" class="ym-button" name="action" value="删除" />
                {% else %}
                    <input type="submit" name="action" value="新增" />
                {% endif %}
                </div>
            </form>
            <table id="tb_comms" class="bordertable">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>小区编号</th>
                    <th>小区名称</th>
                    <th>安装日期</th>
                    <th>行政区</th>
                </tr>
                </thead>
                <tbody></tbody>
            </table>

{% endblock main %}